//
//  CustomView.m
//  UI21_自定义View的xib
//
//  Created by Scott on 16/4/7.
//  Copyright © 2016年 Scott. All rights reserved.
//

#import "CustomView.h"

@interface CustomView ()

@property (strong, nonatomic) IBOutlet UIView *view;

// 声明Block属性.
@property (nonatomic, copy) void (^handleEdit)(UIButton *);

@property (nonatomic, copy) void (^handleDele)(UIButton *);


@end

@implementation CustomView


- (instancetype)initWithCoder:(NSCoder *)aDecoder {
    
    self = [super initWithCoder:aDecoder];
    if (self) {

        [[NSBundle mainBundle] loadNibNamed:@"CustomView" owner:self options:nil];
        
        self.view.frame = self.bounds;
        
        [self addSubview:self.view];
    }
    return self;
}


#pragma mark - 点击事件.
- (IBAction)handleEdit:(id)sender {
    
    // 调用Block.
    self.handleEdit((UIButton *)sender);
    
}

- (IBAction)handleDelete:(id)sender {
    
    // 调用Block.
    self.handleDele((UIButton *)sender);
}



- (void)clickEditBtn:(void (^)(UIButton *editBtn))handlerEdit clickDeleBtn:(void (^)(UIButton *deleBtn))handlerDele {
    
    // Block属性赋值.
    self.handleEdit = handlerEdit;
    self.handleDele = handlerDele;
    
}


@end
